#pragma once
#include <windows.h>
#include "common.h"
#include <string>

namespace TLib
{

	class HotKey
	{
	protected:
		unsigned int vk;
		bool registered;
		int id;
		HWND hWnd;

		// Modifiers
		bool shift;
		bool ctrl;
		bool alt;
		// %

		std::string hotkeyStr;
	private:
		TRAINER_LIB_API void Register();
		TRAINER_LIB_API void UnRegister();
		void recalculateHotkeyStr();
	public:
		inline unsigned int GetVirtualKeyCode() const
		{return vk;}

		inline bool GetShift() const
		{return shift;}

		inline bool GetAlt() const
		{return alt;}

		inline bool GetCtrl() const
		{return ctrl;}

		inline void SetVirtualKeyCode(unsigned int vk)
		{
			bool t = registered;
			if (t)
				UnRegister();
			this->vk = vk;
			if (t)
				Register();
			recalculateHotkeyStr();
		}

		inline void SetShift(bool shift)
		{this->shift = shift;recalculateHotkeyStr();}

		inline void SetCtrl(bool ctrl)
		{this->ctrl = ctrl;recalculateHotkeyStr();}

		inline void SetAlt(bool alt)
		{this->alt = alt;recalculateHotkeyStr();}

		inline bool IsRegistered() const
		{return registered;}

		inline int getId() const
		{return id;}

		inline void setId(int id)
		{
			bool t = registered;
			if (t)
				UnRegister();
			this->id = id;
			if (t)
				Register();
		}

		inline const std::string& getHotkeyString()
		{return hotkeyStr;}

		HotKey
			(
			HWND hWnd,
			unsigned int vk,
			int id = -1,
			bool ctrl = false, 
			bool alt = false, 
			bool shift = false
			);
		~HotKey();
	};

}// Namespace TLib